const fs = require('fs');
//动态加载路由

const useRoutes = function(app){
  fs.readdirSync(__dirname).forEach(file =>{  //遍历文件夹
    if(file ==='index.js') return;
    const router = require(`./${file}`);  //动态加载路由
    app.use(router.routes());
    app.use(router.allowedMethods());
  })
}

module.exports = useRoutes;